#include "ClockDisplay.h"

#include <iostream>

using namespace std;

NumberDispaly::NumberDispaly(int limit, int value)
    : limit(limit), value(value) {}

bool NumberDispaly::increse() {
    value++;
    if (value == limit) {
        value = 0;
        return true;
    }
    return false;
}

void NumberDispaly::print() { cout << setfill('0') << setw(2) << value; }

ClockDisplay::ClockDisplay()
    : hour(NumberDispaly(24)), minute(NumberDispaly(60)) {}

ClockDisplay::ClockDisplay(int hour, int minute)
    : hour(NumberDispaly(24, hour)), minute(NumberDispaly(60, minute)) {}

void ClockDisplay::increse() {
    if (minute.increse()) {
        hour.increse();
    }
}

void ClockDisplay::print() {
    hour.print();
    cout << ':';
    minute.print();
    cout << endl;
}